﻿var _lf = new function () {

    return {

        AddControl: function (options) {
            if (!options.Control || !options.Type) return;
            $control = $(options.Control);

            if (options.Type.mask && options.Type != this.Type.CURRENCY) {
                $control.mask(options.Type.mask);
            } else if (options.Type == this.Type.CURRENCY) {
                $control.maskMoney({
                    symbol: options.Type.symbol,
                    thousands: options.Type.thousandSeparator,
                    decimal: options.Type.decimalSeparator,
                    symbolStay: options.Type.symbolStay
                });
            }

            if (options.Type.datePicker) $control.datepicker();
            if (options.Type.timePicker) $control.timepicker();
            if (options.Type.dateTimePicker) $control.datetimepicker();
            if (options.Type.pickerButton) $(options.Control + '_bt').click(function () { $(options.Control).focus(); });
        },
        Type: function () {
            return {
                DATE: {
                    datePicker: true,
                    pickerButton: true,
                    mask: '99/99/9999'
                },
                CURRENCY: {
                    decimalSeparator: ',',
                    thousandSeparator: '.',
                    symbol: 'R$ ',
                    symbolStay: false
                },
                TIME: {},
                CPF: { mask: '999.999.999-99' },
                CNPJ: { mask: '999.999.999/9999-99' },
                ZIP: { mask: '99999-999' },
                PHONE: { mask: '(99) 9999-9999' },
                TIME: {
                    timePicker: true,
                    mask: '99:99'
                }
            }
        }(),
        Validator: function () {
            return {
                CPF: function (src, args) { args.IsValid = true; },
                CNPJ: function (src, args) { args.IsValid = true; }
            }
        }

    }

}();